package com.xdhl.fu.system.controller;

import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.system.api.domain.SysDictData;
import com.xdhl.fu.system.service.ISysDictDataService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 前台字典接口
 *
 * @author 朱力维
 * @time 2022/6/24 18:25
 */
@RestController
@RequestMapping("/anon/dict/data")
public class PortalDictController {

    @Resource
    private ISysDictDataService dictDataService;

    /**
     * 根据字典类型获取字典数据
     *
     * @param dictType 字典类型
     * @return 字典数据
     */
    @GetMapping("/list/{dictType}")
    public AjaxResult list(@PathVariable("dictType") String dictType) {
        SysDictData sysDictData = new SysDictData();
        sysDictData.setDictType(dictType);
        List<SysDictData> list = dictDataService.selectDictDataList(sysDictData);
        return AjaxResult.success(list);
    }
}
